# Contributor: Diaz Devera Victor <vitronic2@gmail.com>
# Maintainer: Díaz Urbaneja Diego <sodomon2@gmail.com>
pkgname=openspades
pkgver=0.1.3
_resource_version=r33
pkgrel=5
pkgdesc="open-source voxel firt person shooter"
url="http://openspades.yvt.jp/"
arch="x86_64 x86" #disabled for the other architectures due to compiling problems
license="GPL-3.0-only"
depends="bash openal-soft glew opus libjpeg-turbo libxinerama libxft zip"
makedepends="
	cmake
	curl-dev
	freetype-dev
	glew-dev
	grep
	imagemagick
	libjpeg-turbo-dev
	libxft-dev
	libxinerama-dev
	openal-soft-dev
	opus-dev
	opusfile-dev
	samurai
	sdl2-dev
	sdl2_image-dev
	"
subpackages="$pkgname-doc"
options="!check" #no testsuite
source="$pkgname-$pkgver.zip::https://github.com/yvt/openspades/archive/v$pkgver.zip
	https://github.com/yvt/openspades-paks/releases/download/$_resource_version/OpenSpadesDevPackage-$_resource_version.zip
	fix-resources.patch"

build() {
	cmake -G Ninja -B build \
		-DCMAKE_INSTALL_PREFIX:PATH=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DOPENSPADES_RESDIR=/usr/share/$pkgname/Resources \
		-DOPENSPADES_INSTALL_RESOURCES=share/$pkgname/Resources \
		-DOPENSPADES_INSTALL_BINARY=bin
	cmake --build build

	# need to be installed by cmake
	mv "$srcdir/Nonfree/pak000-Nonfree.pak" build/Resources/
	mv "$srcdir/OfficialMods/font-unifont.pak" build/Resources/
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	install -Dm644 "$srcdir"/Nonfree/LICENSE.md "$pkgdir"/usr/share/doc/openspades/ASSETS_LICENSE
}

sha512sums="
c7164dc5c9ac67ec20ef174b18e2ed7383fbe8ccd2d2e725b92256ee58273b96d6c2fa106ea7f8f196505f847340e381c221f97fe797a040575bb2dd6e228e6c  openspades-0.1.3.zip
eb16dee8adfdd93388eac6309908811af02afdcdd6d009e2ab30b87a6b9bb495e77d3de750af18a3209dcf01ddb8400a6b03c1d570f1b77f8a1d2e5f26eb329e  OpenSpadesDevPackage-r33.zip
f9d01fb4443c5cc8a60ef1d115bff21ddbd6e1ee606391d04962228c5b986b5ec27972350aa921f6837e8d73435ba84abdbd89adc1767282625d15defa947ebe  fix-resources.patch
"
